package com.kzw.oa.model.system;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import com.google.gson.annotations.Expose;

public class Dictionary extends com.kzw.core.model.BaseModel {

	@Expose
	protected Long dicId;
	@Expose
	protected String itemName;
	@Expose
	protected String itemValue;
	@Expose
	protected String descp;
	@Expose
	protected Short sn;
	@Expose
	protected GlobalType globalType;
	@Expose
	protected Long proTypeId;

	// 所属父结点
	protected Dictionary parentDict;
	// 代码
	private String code;

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Dictionary getParentDict() {
		return parentDict;
	}

	public void setParentDict(Dictionary parentDict) {
		this.parentDict = parentDict;
	}

	public Long getProTypeId() {
		return proTypeId;
	}

	public void setProTypeId(Long aValue) {
		if (aValue == null) {
			globalType = null;
		} else if (globalType == null) {
			globalType = new GlobalType(aValue);

		} else {
			globalType.setProTypeId(aValue);
		}
	}

	/**
	 * Default Empty Constructor for class Dictionary
	 */
	public Dictionary() {
		super();
	}

	/**
	 * Default Key Fields Constructor for class Dictionary
	 */
	public Dictionary(Long in_dicId) {
		this.setDicId(in_dicId);
	}

	/**
	 * * @return Long
	 * 
	 * @hibernate.id column="dicId" type="java.lang.Long"
	 *               generator-class="native"
	 */
	public Long getDicId() {
		return this.dicId;
	}

	/**
	 * Set the dicId
	 */
	public void setDicId(Long aValue) {
		this.dicId = aValue;
	}

	/**
	 * * @return String
	 * 
	 * @hibernate.property column="itemName" type="java.lang.String" length="64"
	 *                     not-null="true" unique="false"
	 */
	public String getItemName() {
		return this.itemName;
	}

	/**
	 * Set the itemName
	 * 
	 * @spring.validator type="required"
	 */
	public void setItemName(String aValue) {
		this.itemName = aValue;
	}

	/**
	 * * @return String
	 * 
	 * @hibernate.property column="itemValue" type="java.lang.String"
	 *                     length="128" not-null="true" unique="false"
	 */
	public String getItemValue() {
		return this.itemValue;
	}

	/**
	 * Set the itemValue
	 * 
	 * @spring.validator type="required"
	 */
	public void setItemValue(String aValue) {
		this.itemValue = aValue;
	}

	/**
	 * * @return String
	 * 
	 * @hibernate.property column="descp" type="java.lang.String" length="256"
	 *                     not-null="false" unique="false"
	 */
	public String getDescp() {
		return this.descp;
	}

	/**
	 * Set the descp
	 */
	public void setDescp(String aValue) {
		this.descp = aValue;
	}

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof Dictionary)) {
			return false;
		}
		Dictionary rhs = (Dictionary) object;
		return new EqualsBuilder().append(this.dicId, rhs.dicId)
				.append(this.itemName, rhs.itemName)
				.append(this.itemValue, rhs.itemValue)
				.append(this.descp, rhs.descp).isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973).append(this.dicId)
				.append(this.itemName).append(this.itemValue)
				.append(this.descp).toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this).append("dicId", this.dicId)
				.append("itemName", this.itemName)
				.append("itemValue", this.itemValue)
				.append("descp", this.descp).toString();
	}

	public GlobalType getGlobalType() {
		return globalType;
	}

	public void setGlobalType(GlobalType globalType) {
		this.globalType = globalType;
	}

	public Short getSn() {
		return sn;
	}

	public void setSn(Short sn) {
		this.sn = sn;
	}

	public Long getParentDictId() {
		return this.getParentDict() == null ? null : this.getParentDict()
				.getDicId();
	}

	public void setParentDictId(Long aValue) {
		if (aValue == null) {
			parentDict = null;
		} else if (parentDict == null) {
			parentDict = new Dictionary(aValue);
			parentDict.setVersion(new Integer(0));// set a version to cheat
													// hibernate only
		} else {
			parentDict.setDicId(aValue);
		}
	}

	public String getParentDictName() {
		return this.getParentDict() == null ? null : this.getParentDict()
				.getItemValue();
	}
}
